# frozen_string_literal: true

{{#generated_src_warning}}
{{generated_src_warning}}
{{/generated_src_warning}}
module {{module_name}}
  module EventStreams
    {{#input_eventstreams}}
    class {{class_name}}

      def initialize
        @event_emitter = Aws::EventEmitter.new
      end

      {{#event_entries}}
      {{param_hash}}
      def signal_{{name}}_event(params = {})
        @event_emitter.emit(:{{name}}, params)
      end

      {{/event_entries}}
      def signal_end_stream
        @event_emitter.emit(:end_stream, {})
      end

      # @api private
      # @return Aws::EventEmitter
      attr_reader :event_emitter

    end

    {{/input_eventstreams}}
    {{#output_eventstreams}}
    class {{class_name}}

      def initialize
        @event_emitter = Aws::EventEmitter.new
      end

      {{#types}}
      def on_{{.}}_event(&block)
        @event_emitter.on(:{{.}}, block) if block_given?
      end

      {{/types}}
      def on_error_event(&block)
        @event_emitter.on(:error, block) if block_given?
      end

      def on_initial_response_event(&block)
        @event_emitter.on(:initial_response, block) if block_given?
      end

      def on_unknown_event(&block)
        @event_emitter.on(:unknown_event, block) if block_given?
      end

      def on_event(&block)
        {{#types}}
        on_{{.}}_event(&block)
        {{/types}}
        on_error_event(&block)
        on_initial_response_event(&block)
        on_unknown_event(&block)
      end

      # @api private
      # @return Aws::EventEmitter
      attr_reader :event_emitter

    end
    {{/output_eventstreams}}

  end
end

